<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link
	href="${pageContext.request.contextPath }/admin/assets/css/bootstrap.min.css"
	rel="stylesheet" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/admin/css/style.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/admin/assets/css/ace.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/admin/assets/css/font-awesome.min.css" />
<link
	href="${pageContext.request.contextPath }/admin/Widget/icheck/icheck.css"
	rel="stylesheet" type="text/css" />
<script
	src="${pageContext.request.contextPath }/admin/js/jquery-1.9.1.min.js"></script>
<script
	src="${pageContext.request.contextPath }/admin/assets/js/bootstrap.min.js"></script>
<script
	src="${pageContext.request.contextPath }/admin/assets/js/typeahead-bs2.min.js"></script>
<script
	src="${pageContext.request.contextPath }/admin/assets/js/jquery.dataTables.min.js"></script>
<script
	src="${pageContext.request.contextPath }/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/admin/js/H-ui.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/admin/js/H-ui.admin.js"></script>
<script
	src="${pageContext.request.contextPath }/admin/assets/layer/layer.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath }/admin/assets/laydate/laydate.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath }/admin/assets/dist/echarts.js"></script>
<script src="${pageContext.request.contextPath }/admin/js/lrtk.js"
	type="text/javascript"></script>
<link
	href="${pageContext.request.contextPath }/admin/layui-v2.4.5/layui/css/layui.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath }/admin/layui-v2.4.5/layui/layui.js"></script>
<title>品牌管理</title>
</head>
<body>
	<div class="page-content clearfix">
		<div id="brand_style">
			<div class="search_style">
				<div class="title_names">搜索查询</div>
				<ul class="search_content clearfix">
					<li><label class="l_f">服务名称</label><input name="" type="text"
						class="text_add" placeholder="输入服务名称" style="width: 250px" /></li>
					<li style="width: 90px;"><button type="button"
							class="btn_search">
							<i class="icon-search"></i>查询
						</button></li>
				</ul>
			</div>
			<div class="border clearfix">
				<span class="l_f"> <a data-toggle="modal"
					href="#mySaveBservice" title="添加服务"
					class="btn btn-warning Order_form"><i class="icon-plus"></i>添加服务</a>
					<a id="batchDe" href="javascript:ovid()" class="btn btn-danger"><i
						class="icon-trash"></i>批量删除</a>
				</span> <span class="r_f">共：<b> <s:property
							value="map.bserviceList.size()" />
				</b>个服务
				</span>
			</div>
			<!--品牌列表-->
			<div class="table_menu_list">
				<table class="table table-striped table-bordered table-hover"
					id="sample-table">
					<thead>
						<tr>
							<th width="25px"><label><input type="checkbox"
									class="ace"><span class="lbl"></span></label></th>
							<th width="80px">服务类型编号</th>
							<th width="50px">服务类型名称</th>
							<th width="120px">服务类型价格</th>
							<th width="120px">服务类型简绍</th>
							<th width="200px">操作</th>
						</tr>
					</thead>
					<tbody>
						<s:iterator value="map.bserviceList">
							<tr>
								<td width="25px"><label><input type="checkbox"
										class="ace" value="${bserviceId }"><span class="lbl"></span></label></td>
								<td width="80px">${bserviceId }</td>
								<td width="50px">${bserviceName }</td>
								<td width="120px">${bservicePrice }</td>
								<td width="120px">${bserviceIntroduce }</td>
								<td class="td-manage"><a title="编辑"
									onclick="member_edit('${bserviceId }')"
									href="#myUdpateBservice" class="btn btn-xs btn-info "
									data-toggle="modal"><i class="icon-edit bigger-120"></i></a> <a
									title="删除" href="javascript:;"
									onclick="member_del(this,'${bserviceId }')"
									class="btn btn-xs btn-warning"><i
										class="icon-trash  bigger-120"></i></a></td>
							</tr>
						</s:iterator>
					</tbody>
				</table>
			</div>
		</div>
	</div>

	<!-- 模态框（Modal） -->
	<form action="${pageContext.request.contextPath }/saveBservice"
		method="post">
		<div class="modal fade" id="mySaveBservice" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="vmodal"
							aria-hidden="true">×</button>
						<h4 class="modal-title" id="myModalLabel">添加</h4>
					</div>
					<div class="modal-body">
						<table class="table table-bordered">
							<tr>
								<td>服务名称：</td>
								<td>
									<div class="form-group input-group-sm" style="width: 344px">
										<input type="text" class="form-control" placeholder="服务名称"
											name="bserviceName" id="">
									</div>
								</td>
							</tr>
							<tr>
								<td>服务价格：</td>
								<td>
									<div class="form-group input-group-sm" style="width: 344px">
										<input type="text" class="form-control" placeholder="服务价格"
											name="bservicePrice" id="">
									</div>
								</td>
							</tr>
							<tr>
								<td>服务简绍：</td>
								<td>
									<div class="form-group" style="resize: none">
										<textarea class="form-control" rows="5"
											name="bserviceIntroduce" id=""></textarea>
									</div>
								</td>
							</tr>
						</table>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="submit" class="btn btn-primary">提交</button>
					</div>
				</div>
			</div>
		</div>
	</form>

	<!--   ---------------------------------------------------------------------------------------               -->
	<form action="${pageContext.request.contextPath }/udpateBservice"
		method="post">
		<div class="modal fade" id="myUdpateBservice" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="vmodal"
							aria-hidden="true">×</button>
						<h4 class="modal-title" id="myModalLabel">添加</h4>
					</div>
					<div class="modal-body">
						<input type="hidden" name="bserviceId" value="" id="bserviceId" />
						<table class="table table-bordered">
							<tr>
								<td>服务名称：</td>
								<td>
									<div class="form-group input-group-sm" style="width: 344px">
										<input type="text" class="form-control" placeholder="服务名称"
											name="bserviceName" id="bserviceName">
									</div>
								</td>
							</tr>
							<tr>
								<td>服务价格：</td>
								<td>
									<div class="form-group input-group-sm" style="width: 344px">
										<input type="text" class="form-control" placeholder="服务价格"
											name="bservicePrice" id="bservicePrice">
									</div>
								</td>
							</tr>
							<tr>
								<td>服务简绍：</td>
								<td>
									<div class="form-group" style="resize: none">
										<textarea class="form-control" rows="5"
											name="bserviceIntroduce" id="bserviceIntroduce"></textarea>
									</div>
								</td>
							</tr>
						</table>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="submit" class="btn btn-primary">提交</button>
					</div>
				</div>
			</div>
		</div>
	</form>


</body>
<script>
$(function(){
	batchDes();
});

	//初始化宽度、高度  
	$(".chart_style").height($(window).height());
	$(".table_menu_list").height($(window).height());
	$(".table_menu_list ").width($(window).width());
	//当文档窗口发生改变时 触发  
	$(window).resize(function() {
		$(".chart_style").height($(window).height());
		$(".table_menu_list").height($(window).height());
		$(".table_menu_list").width($(window).width());
	});
	//图层隐藏限时参数		 
	$(function() {
		$("#category").fix({
			float : 'left',
			//minStatue : true,
			skin : 'green',
			durationTime : false,
			stylewidth : '400',
			spacingw : 30,//设置隐藏时的距离
			spacingh : 440,//设置显示时间距
		});
	});
	//面包屑返回值
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.iframeAuto(index);
	$('.Order_form ,.brond_name').on('click', function() {
		var cname = $(this).attr("title");
		var cnames = parent.$('.Current_page').html();
		var herf = parent.$("#iframe").attr("src");
		parent.$('#parentIframe span').html(cname);
		parent.$('#parentIframe').css("display", "inline-block");
		parent.$('.Current_page').attr("name", herf).css({
			"color" : "#4c8fbd",
			"cursor" : "pointer"
		});
		//parent.$('.Current_page').html("<a href='javascript:void(0)' name="+herf+">" + cnames + "</a>");
		parent.layer.close(index);

	});
	function generateOrders(id) {
		window.location.href = "Brand_detailed.html?=" + id;
	};
	/*品牌-查看*/
	function member_show(title, url, id, w, h) {
		layer_show(title, url, w, h);
	}

	/*品牌-编辑*/
	function member_edit(id) {
		$.ajax({
			url:"${pageContext.request.contextPath }/findBserviceById?bserviceId="+id,
			dataType:'json',
			success:function(msg){
				 $('#bserviceId').val(msg.bservice.bserviceId);
				$('#bservicePrice').val(msg.bservice.bservicePrice);
				$('#bserviceName').val(msg.bservice.bserviceName); 
				$('#bserviceIntroduce').val(msg.bservice.bserviceIntroduce); 
			},error:function(){
				alert("失败！");
			}
		});
		stockidJUD();
	}

	/*品牌-删除*/
	function member_del(obj, id) {
		layer.confirm('确认要删除吗？', function(index) {
			 $.ajax({
				url:'${pageContext.request.contextPath }/deleteBservice',
				type:"POST",
				data:'bserviceId='+id,
				dataType:'json',
				success:function(msg){
					if(msg){
						$(obj).parents("tr").remove();
						layer.msg('已删除!', {
							icon : 1,
							time : 1000
						});
					}
				},error:function(){
					layer.msg('删除失败,有引用!', {
						icon : 1,
						time : 1000
					});
				}
			}); 
		});
	}
	
	//批量删除
	var batchDes = function(){
		$('#batchDe').click(function(){
			var checkedObj = [];
			var i=0;
			var checks ="";
			$(":checkbox:checked").each(function(){//获取所有选中的按钮
					if($(this).val()!='on'){
						checks+=$(this).val()+",";
						checkedObj[i++]=this;
					}
			});
			if(checks==null||checks==""){
				layer.msg('请选中！！', {
					icon : 1,
					time : 1000
				});
				return ;
			}
			layer.confirm('确认要删除吗？', function(index) {
				 $.ajax({
					url:'${pageContext.request.contextPath }/batcheDeleteBservice',
					type:"POST",
					data:'bserviceIds='+checks,
					dataType:'json',
					success:function(msg){
						if(msg){
							for(var i=0;i<checkedObj.length;i++){
								$(checkedObj[i]).parents("tr").remove();
							}
							layer.msg('已删除!', {
								icon : 1,
								time : 1000
							});
							checks="";
							checkedObj.clean();
						}
					},error:function(){
						layer.msg('删除失败!', {
							icon : 1,
							time : 1000
						});
					}
				}); 
			});
			
		});
	}
	
	
	
	laydate({
		elem : '#start',
		event : 'focus'
	});

</script>

<script type="text/javascript">
	jQuery(function($) {
		var oTable1 = $('#sample-table').dataTable( {
		"aaSorting": [[ 0, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[4,5]}// 制定列不参与排序
		] } );
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});	
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			});
</script>



</html>